import router from './router'
import store from '@/store/index.js'
// import { agentFindByAgentNo } from '@/api/agent'

// 路由守卫
router.beforeEach((to : any, from : any, next : any) => {
	console.log(to)
	// 网页标题
	if (to.query.bindType == 1) {
		document.title = '绑定数'
	} else if(to.query.bindType == 2){
		document.title = '未唤醒预警'
	}else if(to.query.bindType == 3){
		document.title = '无交易预警'
	}else {
		if (to.meta.title) {
			document.title = to.meta.title
		}
	}
	console.log(to.query)
	store.dispatch('data/GetRouterInfo', to) // 储存路由信息
	if (to.query.token) {
		store.dispatch('user/GetUserInfo', to.query.token)
	}
	if (to.query.agentNo) {
		store.dispatch('user/GetUserInfo1', to.query.agentNo)
	}
	if (to.query.os) {
		store.dispatch('user/GetOs', to.query.os)
	}
	if (to.query.version) {
		store.dispatch('user/GetVersion', to.query.version)
	}
	if (to.query.invitation) {
		store.dispatch('user/GetInvitation', to.query.invitation)
	}
	next()
	// if (!store.state.user.userInfo.agentBean.id) {
	//     if (to.meta.show) {
	//         next()
	//     } else {
	//         agentFindByAgentNo({}).then(res => {
	//             store.dispatch('user/GetUserAllInfo', res.object)
	//             next()
	//         })
	//     }
	// } else {
	//     next()
	// }
})